//
//  DengLuViewController.m
//  UI_HLJ_Frame
//
//  Created by dlios on 15-7-3.
//  Copyright (c) 2015年 毕宏伟. All rights reserved.
//

#import "DengLuViewController.h"

#define WIDTH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height

@interface DengLuViewController ()<UITextFieldDelegate>

@property(nonatomic, retain)UITextField *textFieldNC;
@property(nonatomic, retain)UITextField *textFieldMM;

@property(nonatomic, retain)UIButton *buttonDL;
@property(nonatomic ,retain)UIButton *buttonQX;

@end

@implementation DengLuViewController

- (void)dealloc
{
    [_textFieldNC release];
    [_textFieldMM release];
    [_buttonDL release];
    [_buttonQX release];
    [super dealloc];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"登陆";
    [self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"登陆的背景图片"]]];
    
    // 建立label
    // 登陆名
    UILabel *labelDLNC = [[UILabel alloc] initWithFrame:CGRectMake(WIDTH * 0.5 / 3, HEIGHT * 2.5 / 10, WIDTH * 2.5 / 10, HEIGHT * 1.8 / 20)];
    [self.view addSubview:labelDLNC];
//    labelDLNC.backgroundColor = [UIColor orangeColor];
    labelDLNC.text = @"登录名 :";
    labelDLNC.font = [UIFont systemFontOfSize:18];
    [labelDLNC release];
    
    // 密码
    UILabel *labelDLMM = [[UILabel alloc] initWithFrame:CGRectMake(WIDTH * 0.5 / 3, HEIGHT * 3.5 / 10, WIDTH * 2.5 / 10, HEIGHT * 1.8 / 20)];
    [self.view addSubview:labelDLMM];
//    labelDLMM.backgroundColor = [UIColor orangeColor];
    labelDLMM.text = @"密码 :";
    labelDLMM.font = [UIFont systemFontOfSize:18];
    [labelDLMM release];
    
    // 建立textField
    // 输入登录名
    self.textFieldNC = [[UITextField alloc] initWithFrame:CGRectMake(WIDTH * 0.9 / 2, HEIGHT * 2.5 / 10, WIDTH * 4 / 10, HEIGHT * 1.2 / 20)];
    [self.view addSubview:self.textFieldNC];
//    self.textFieldNC.backgroundColor = [UIColor orangeColor];
    self.textFieldNC.layer.borderWidth = 1;
    self.textFieldNC.layer.cornerRadius = 10;
    self.textFieldNC.delegate = self;
    self.textFieldNC.placeholder = @"请输入登陆名";
    self.textFieldNC.clearButtonMode = UITextFieldViewModeAlways;
    [_textFieldNC release];
    
    // 输入密码
    self.textFieldMM = [[UITextField alloc] initWithFrame:CGRectMake(WIDTH * 0.9 / 2, HEIGHT * 3.5 / 10, WIDTH * 4 / 10, HEIGHT * 1.2 / 20)];
    [self.view addSubview:self.textFieldMM];
//    self.textFieldMM.backgroundColor = [UIColor orangeColor];
    self.textFieldMM.layer.borderWidth = 1;
    self.textFieldMM.layer.cornerRadius = 10;
    self.textFieldMM.delegate = self;
    self.textFieldMM.placeholder = @"请输入密码";
    self.textFieldMM.clearButtonMode = UITextFieldViewModeAlways;
    self.textFieldMM.secureTextEntry = YES;
    [_textFieldMM release];
    
    // 建立2个button
    // 保存按钮
    self.buttonDL = [UIButton buttonWithType:UIButtonTypeSystem];
    self.buttonDL.frame = CGRectMake(WIDTH * 0.7 / 3, HEIGHT * 5 / 10, WIDTH * 2 / 10, HEIGHT * 1 / 20);
    [self.view addSubview:self.buttonDL];
    self.buttonDL.layer.borderWidth = 1;
    self.buttonDL.layer.cornerRadius = 10;
    [self.buttonDL setTitle:@"确定" forState:UIControlStateNormal];
    [self.buttonDL addTarget:self action:@selector(clickDL:) forControlEvents:UIControlEventTouchUpInside];
    
    // 取消按钮
    self.buttonQX = [UIButton buttonWithType:UIButtonTypeSystem];
    self.buttonQX.frame = CGRectMake(WIDTH * 1.6 / 3, HEIGHT * 5 / 10, WIDTH * 2 / 10, HEIGHT * 1 / 20);
    [self.view addSubview:self.buttonQX];
    self.buttonQX.layer.borderWidth = 1;
    self.buttonQX.layer.cornerRadius = 10;
    [self.buttonQX setTitle:@"取消" forState:UIControlStateNormal];
    [self.buttonQX addTarget:self action:@selector(clickQX:) forControlEvents:UIControlEventTouchUpInside];

//    UIBarButtonItem *bar = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:nil action:nil];
//    self.navigationItem.backBarButtonItem = bar;
    
    
}

// 确定按钮的跳转,返回首页
- (void)clickDL:(UIButton *)button{
    
    
    
    [self.navigationController popToRootViewControllerAnimated:YES];
    
}


// 取消按钮的跳转,返回上一页
- (void)clickQX:(UIButton *)button{
    
    [self.navigationController popViewControllerAnimated:YES];
    
}




#pragma mark 点击空白回收键盘
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    
    [self.textFieldNC resignFirstResponder];
    [self.textFieldMM resignFirstResponder];
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
